﻿Public Class frmOpcion1

    Private WithEvents AsteriskSocket As New Zocalo

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        With AsteriskSocket
            .RemoteHost = frmPanelPrincipal.txtServidor.Text
            .RemotePort = frmPanelPrincipal.txtPuerto.Text
            .Connect()
            .SendData("Action: Login" & vbCrLf & "UserName: " & frmPanelPrincipal.txtUsuario.Text & vbCrLf & "Secret: " & frmPanelPrincipal.txtClave.Text & vbCrLf & vbCrLf)
            'Timer1.Enabled = True

        End With
    End Sub

    Private Sub AsteriskSocket_DataArrival(ByVal Value As String) Handles AsteriskSocket.DataArrival
        Try
            Dim instance As InvalidOperationException
            Dim vCadena As String = Value
            If Len(TextBox1.Text) > 3000 Then TextBox1.Text = ""
            TextBox1.Text = TextBox1.Text + vCadena
            TextBox1.Select(TextBox1.Text.Length, 0)
            TextBox1.ScrollToCaret()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        AsteriskSocket.Close()
        Me.Close()
    End Sub

    Private Sub AsteriskSocket_Error(ByVal Value As String) Handles AsteriskSocket.Error
        'Debug.Print(Now, Value)
    End Sub
End Class
